package com.tinghua.consumer;

import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;


import java.util.Date;

@Slf4j
@Component
public class QueueConsumer {

    //channel参数虽然下面没有使用，但其实下面这个注解是需要用到的，所以这个Channel的包导错会导致运行异常
    @RabbitListener(queues = "QD")
    public void receiveD(Message message, Channel channel) throws Exception{
        String msg = new String(message.getBody());
        log.info("在{}时刻死信队列接收到消息：{}", new Date(), msg);
    }
}
